using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    /// <summary> 
    ///Author: daiduong19051986@gmail.com 
    /// <summary>
    public class TVC_RFITMControl
    {
        private TVC_RFITMDataAccess _objDAO;
        #region Local Variable


        #endregion Local Variable

        #region Method
        public TVC_RFITMControl(String bus)
        {
            business = bus;
            _objDAO = new TVC_RFITMDataAccess();
        }
        public TVC_RFITMInfo Get(string db, String ItemCode, ref string sErr)
        {
            return _objDAO.Get(db, ItemCode, ref sErr);

        }

        public DataTable GetAll(string db, ref string sErr)
        {
            return _objDAO.GetAll(db, ref sErr);
        }

        public Int32 Add(string db, TVC_RFITMInfo obj, ref string sErr)
        {
            return _objDAO.Add(db, obj, ref sErr);
        }

        public string Update(string db, TVC_RFITMInfo obj)
        {
            return _objDAO.Update(db, obj);

        }

        public string Delete(string db, String ItemCode)
        {
            return _objDAO.Delete(db, ItemCode);

        }
        public Boolean IsExist(string db, String ItemCode)
        {
            return _objDAO.IsExist(db, ItemCode);

        }


        public string InsertUpdate(string db, TVC_RFITMInfo obj)
        {
            string sErr = "";
            if (IsExist(db, obj.ItemCode))
                sErr = _objDAO.Update(db, obj);
            else _objDAO.Add(db, obj, ref sErr);
            return sErr;
        }

        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);
        }

        public DataTable ToTransferInStruct()
        {
            return TVC_RFITMInfo.ToDataTable();
        }

        public string TransferIn(string db, DataRow row)
        {
            TVC_RFITMInfo inf = new TVC_RFITMInfo(row);
            return InsertUpdate(db, inf);
        }
        #endregion Method


        public string business { get; set; }

        public DataTable GetFilter(string db, string strFilter, ref string sErr)
        {
            return _objDAO.GetFilter(db, strFilter, ref sErr);
        }

        public void Update(string db, string aItem, double aAve_Cost, ref string sErr)
        {
            _objDAO.Update(db, aItem, aAve_Cost, ref sErr);
        }

        public bool SetTransaction(object _trans)
        {
            return _objDAO.SetTransaction(_trans);
        }

        public DataTable GetModelPN(string db, ref string sErr)
        {
            return _objDAO.GetModelPN(db, ref sErr);
        }

        public bool DesIsExist(string db, String Description, String ItemCode)
        {
            return _objDAO.DesIsExist(db, Description, ItemCode);
        }

        public bool ANAL_I4IsExist(string db, string ANAL_I4, string ItemCode)
        {
            return _objDAO.ANAL_I4IsExist(db, ANAL_I4, ItemCode);
        }
    }
}
